/*
 * @Author: your name
 * @Date: 2020-12-08 11:29:32
 * @LastEditTime: 2020-12-16 09:27:19
 * @LastEditors: Please set LastEditors
 * @Description: 设置页面的rem值
 * @FilePath: \gitee-h5-template\js\setRem.js
 */
(function() {
    window.zzMixinSetRem = {
        data(){
            return {
                // 显示页面
                zzShowPage:false
            };
        },
        mounted(){
            if (!document.addEventListener) return;
            // --- 动态设置内容区最小高度
            zzSetIframeFluidMH(40);
            //
            //this.recalc();
            //window.onresize = this.recalc;
            //document.addEventListener('DOMContentLoaded', this.recalc, true);
            //
            this.zzShowPage = true;
        },
        methods:{
            getBrowserInterfaceSize(){
                var pageWidth = window.innerWidth;
                var pageHeight = window.innerHeight;
        
                if (typeof pageWidth !== 'number') {
                    // 在标准模式下面
                    if (document.compatMode === 'CSS1Compat') {
                        pageWidth = document.documentElement.clientWidth;
                        pageHeight = document.documentElement.clientHeight;
                    } else {
                        pageWidth = document.body.clientWidth;
                        pageHeight = window.body.clientHeight;
                    }
                }
                return {
                    pageWidth: pageWidth,
                    pageHeight: pageHeight
                }
            },
            recalc(){
                let doc = document;
                let win = window;
                var docEl = doc.documentElement;
                var calHeight = this.getBrowserInterfaceSize() ? this.getBrowserInterfaceSize().pageHeight : win.screen.availHeight;
                var calWidth = this.getBrowserInterfaceSize() ? this.getBrowserInterfaceSize().pageWidth : win.screen.availWidth;
                var clientWidth = this.getBrowserInterfaceSize() ? this.getBrowserInterfaceSize().pageWidth : docEl.clientWidth;
                if (!clientWidth) return
                docEl.style.fontSize = 100 * (clientWidth / 750) + "px";
                /* docEl.style.fontSize = 20 * (clientWidth / 320) + 'px'; */
                //docEl.style.width = doc.body.style.calWidth = calWidth + 'px'
                //docEl.style.height = doc.body.style.height = calHeight + 'px'
            }
        }
    };
})();